const connection = require("../db")
const md5Password = require("../utils/md5")
class userServer {
  iscanadd(username) {
    // 查看用户名是否被占用
    const statement = `SELECT *  FROM user where username = ?`
    return connection.execute(statement, [username])
  }
  regutor(username, password) {
    const statement = `INSERT INTO user (username,password) VALUES(?,?)`
    return connection.execute(statement, [username, md5Password(password)])
  }
  login(username, password) {
    const statement = "select * from user where username=? and password=?"
    return connection.execute(statement, [username, md5Password(password)])
  }
}

module.exports = new userServer()
